/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 * <p>Project: app2022 - Str6
 * <p>Powered by webrx On 2022-01-12 16:42:51
 *
* @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Str6 {
    public static void main(String[] args) {

        //String f = "c:/users/abc/j.jpg";
        String f = "/home/www/upload/p.png";
        System.out.println(f);

        //String f = "c:/users/abc/20220112164130_242100.jpg";

        f = f.toLowerCase();

        String s1 = f.contains("/") ? f.substring(0,f.lastIndexOf("/")+1) : f.substring(0,f.lastIndexOf("\\")+1);
        System.out.println(s1);
        //String s2 = f.substring(f.length()-3);
        String s2 = f.substring(f.lastIndexOf("."));
        System.out.println(s2);
        System.out.println(f);

        var sdf = new SimpleDateFormat("yyyyMMddHHmmssS");
        var rand = new Random();
        var num = String.format("%s_%06d",sdf.format(new Date()),rand.nextInt(1,999999));
        String ff = s1+num+s2;
        System.out.println(ff);

        var u = UUID.randomUUID().toString().toLowerCase();
        String ff2 = s1.concat(u).concat(s2);
        System.out.println(ff2);
    }
}
